package org.grow.stable.security.domain;


import lombok.Data;

import javax.persistence.*;
import java.util.List;

@Entity
@Data
public class Permission {
    @Id
    private String permissionId;
    private String name;
    private String path;
    private String description;
    private Integer groupIndex;
    @Enumerated(EnumType.STRING)
    private ResourceType resourceType = ResourceType.BUTTON;

    public enum ResourceType {
        BUTTON, MENU
    }

    @ElementCollection(fetch = FetchType.EAGER)
    //表名字 共三列 一列是关联的username 一列是List<String>中的string 一列是可有可无的List_index
    //@JoinTable

    @JoinTable(name = "permission_role",joinColumns = {
            @JoinColumn(name = "permission_id_fk",referencedColumnName = "permissionId")
    })
    @Column(name = "role")
    @Enumerated(EnumType.STRING)
    private List<Role> roles;

}
